package com.team.sns.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
public class User implements Serializable {

	private static final long serialVersionUID = 1L;

	private Integer id;
	private String username = "";
	private String password = "";
	private Gender gender;
	private String email;
	private String photoPath;
	private String webProfileLink;
	private String webAddFriendLink;
	private Date regDate = new Date();
	private Date lastAccessDate;
	private Boolean active = false;
	private Integer msg_count = 0;//消息发布数量
	private Integer fans_count = 0;//粉丝数量
	private Integer follow_count = 0;//关注者数量
	@Column
	public Integer getMsg_count() {
		return msg_count;
	}

	public void setMsg_count(Integer msgCount) {
		msg_count = msgCount;
	}
	@Column
	public Integer getFans_count() {
		return fans_count;
	}

	public void setFans_count(Integer fansCount) {
		fans_count = fansCount;
	}
	@Column
	public Integer getFollow_count() {
		return follow_count;
	}

	public void setFollow_count(Integer followCount) {
		follow_count = followCount;
	}

	private List<Actor> actors;

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @JoinTable(name = "UserActor", joinColumns = { @JoinColumn(name = "actorId") }, inverseJoinColumns = { @JoinColumn(name = "userId") })
	public List<Actor> getActors() {
		return actors;
	}

	public void setActors(List<Actor> actors) {
		this.actors = actors;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(length = 20, unique = true)
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Column(length = 32, nullable = false)
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Enumerated(EnumType.STRING) @Column(nullable = false, length = 11)
	public Gender getGender() {
		return gender;
	}

	public void setGender(Gender gender) {
		this.gender = gender;
	}

	@Column(length = 50, nullable = false)
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Column(length = 2000)
	public String getPhotoPath() {
		return photoPath;
	}

	public void setPhotoPath(String photoPath) {
		this.photoPath = photoPath;
	}

	@Column(length = 200)
	public String getWebProfileLink() {
		return webProfileLink;
	}

	public void setWebProfileLink(String webProfileLink) {
		this.webProfileLink = webProfileLink;
	}

	@Column(length = 200)
	public String getWebAddFriendLink() {
		return webAddFriendLink;
	}

	public void setWebAddFriendLink(String webAddFriendLink) {
		this.webAddFriendLink = webAddFriendLink;
	}

	@Column(length = 22, nullable = false)
	@Temporal(TemporalType.TIMESTAMP)
	public Date getRegDate() {
		return regDate;
	}

	public void setRegDate(Date regDate) {
		this.regDate = regDate;
	}

	@Column(length = 22)
	@Temporal(TemporalType.TIMESTAMP)
	public Date getLastAccessDate() {
		return lastAccessDate;
	}

	public void setLastAccessDate(Date lastAccessDate) {
		this.lastAccessDate = lastAccessDate;
	}

	@Column(nullable = false)
	public Boolean getActive() {
		return active;
	}

	public void setActive(Boolean active) {
		this.active = active;
	}

}
